// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'

//ztree 定义的初始化样式
import '@/assets/plugin/ztree/css/zTreeStyle.css';
import '@/assets/plugin/ztree/js/jquery-1.4.4.min.js';
import '@/assets/plugin/ztree/js/jquery.ztree.core.js';
import '@/assets/plugin/ztree/js/jquery.ztree.excheck.js';
// import 'lib-flexible/flexible.js'
import store from './store'
import Header from '@/components/Header'
import Footer from '@/components/Footer'
Vue.component('Footer',Footer)
Vue.component('Header',Header)

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);


// 路由拦截
import { getToken,removeToken } from '@/utils/auth' // 验权
const whiteList = ['/login','/regist','/forget'] // 不重定向白名单
const authArray = ['/mine','/car','/personal','/address']

router.beforeEach((to,from,next)=>{
  console.log(getToken(),authArray.indexOf(to.path) !== -1)
  if(getToken()){
    next()
  }else{
    // 如果没有登录 判断当前是手机还是pc
    if(authArray.indexOf(to.path) !== -1){
      next({path:'/login'})
    }else{
      next()
    }
  }
})

Vue.config.productionTip = false

// // // 引入地址插件
import VDistpicker from 'v-distpicker'
Vue.component('v-distpicker', VDistpicker)
// 重新引入地址插件
// import { pca, pcaa } from 'area-data'; // v5 or higher
// import 'vue-area-linkage/dist/index.css'; // v2 or higher
// import VueAreaLinkage from 'vue-area-linkage';

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})
